package com.custom.base.ui.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.custom.base.presenter.BasePresenter
import com.custom.base.presenter.view.BaseView


abstract class BaseMvpFragment<T : BasePresenter<*>> : BaseFragment(), BaseView {
    //Presenter泛型，Dagger注入
    lateinit var mPresenter: T

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        super.onCreateView(inflater, container, savedInstanceState)
        return inflater.inflate(setLayout(), null)
    }

    abstract fun setLayout(): Int

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        mPresenter = initComponent()
        initData()
    }

    /**
     * 注册组件
     */
    abstract fun initComponent(): T

    /**
     * 初始化数据
     */
    abstract fun initData()

    override fun showLoading() {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }

    override fun onError(throwable: Throwable) {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }


}
